package com.yunupmall.controller.amdin;

import com.yunupmall.api.fordVO.StatisticsCommtityPO;
import com.yunupmall.api.po.OrderCounts;
import com.yunupmall.api.po.UserCounts;
import com.yunupmall.service.ford.service.StatisticSeriver;
import com.yunupmall.uits.Result;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/statistics")
@AllArgsConstructor
public class StatisticsController {

    private final Result result;

    private final StatisticSeriver statisticSeriver;

    /**
     *商品数据
     * @return
     */
    @GetMapping("/commtityTic")
    public Result<StatisticsCommtityPO> getcommtityTic(){
        try {
            return result.ok(statisticSeriver.getCommtity());
        }catch (Exception e) {
            return result.error(e.getMessage());
        }
    }

    /**
     *用户数据
     * @return
     */
    @GetMapping("/MemberTic")
    public Result<StatisticsCommtityPO> MemberTic(){
        try {
            return result.ok(statisticSeriver.getMemberTic());
        }catch (Exception e) {
            return result.error(e.getMessage());
        }
    }
    /**
     * 订单数据
     */
    @GetMapping("/orderTic")
    public Result<StatisticsCommtityPO> orderTic(){
        try {
            return result.ok(statisticSeriver.getOrderTic());
        }catch (Exception e) {
            return result.error(e.getMessage());
        }
    }
    /**
     * 订单月份统计图
     */
    @GetMapping("/orderYearTic")
    public Result<List<OrderCounts>> orderYearTic(@RequestParam(value = "date") String Date){
        try {
            return result.ok(statisticSeriver.getYearOrderTic(Date));
        }catch (Exception e) {
            return result.error(e.getMessage());
        }
    }
    /**
     * 商品类别数据统计
     */
    @GetMapping("/kindCommtityStatistics")
    public Result<List<OrderCounts>> kindCommtityStatistics(){
        try {
            return result.ok(statisticSeriver.kindCommtityStatistics());
        }catch (Exception e) {
            return result.error(e.getMessage());
        }
    }

}
